package com.kgcx.organization.controller;

import com.kgcx.common.bean.RequestData;
import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.controller.BaseController;
import com.kgcx.organization.domain.Airport;
import com.kgcx.organization.domain.AirportParking;
import com.kgcx.organization.domain.AirportTerminal;
import com.kgcx.organization.service.AirportParkingService;
import com.kgcx.organization.service.AirportService;
import com.kgcx.organization.service.AirportTerminalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description = "机场接口", tags = "机场接口")
@RestController
@RequestMapping("airport")
public class AirportController extends BaseController {
    @Autowired
    private AirportService airportService;

    @Autowired
    private AirportTerminalService airportTerminalService;

    @Autowired
    private AirportParkingService airportParkingService;

    @ApiOperation(value = "查询机场", httpMethod = "GET", notes = "这是用来查询机场的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "机场ID", required = true, paramType = "query", dataType = "String", dataTypeClass = Long.class),
    })
    @GetMapping("getAirport")
    public ReturnData<Airport> getAirport() {
        RequestData requestData = this.getRequestData();
        Airport airport = airportService.getAirport(requestData.getLong("kid"));
        return new ReturnData<>(airport);
    }

    @ApiOperation(value = "查询机场", httpMethod = "GET", notes = "这是用来查询机场的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityName", value = "城市", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "cityId", value = "城市id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping("getAirportList")
    public ReturnData<List<Airport>> getAirportList() {
        RequestData requestData = this.getRequestData();
        List<Airport> airportList = airportService.getAirportList(requestData);
        return new ReturnData(airportList);
    }

    @ApiOperation(value = "新增机场", httpMethod = "POST", notes = "这是用来新增机场的接口")
    @PostMapping("addAirport")
    public ReturnData addAirport(@RequestBody Airport airport) {
        airportService.addAirport(airport);
        return new ReturnData();
    }

    @ApiOperation(value = "修改机场", httpMethod = "POST", notes = "这是用来修改机场的接口")
    @PostMapping("updateAirport")
    public ReturnData updateAirport(@RequestBody Airport airport) {
        airportService.updateAirport(airport);
        return new ReturnData();
    }

    @ApiOperation(value = "删除机场", httpMethod = "POST", notes = "这是用来删除机场的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "用户ID", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @PostMapping("removeAirport")
    public ReturnData removeAirport(@RequestParam Long kid) {
        airportService.removeAirport(kid);
        return new ReturnData();
    }

    @ApiOperation(value = "查询机场航站楼", httpMethod = "GET", notes = "这是用来查询机场航站楼的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityName", value = "城市", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "cityId", value = "城市id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "airportId", value = "机场id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "terminalName", value = "航站楼名称,模糊查询", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping("getAirportTerminalList")
    public ReturnData<List<AirportTerminal>> getAirportTerminalList() {
        RequestData requestData = this.getRequestData();
        List<AirportTerminal> airportTerminalList = airportTerminalService.getAirportTerminalList(requestData);
        return new ReturnData<>(airportTerminalList);
    }

    @ApiOperation(value = "新增机场航站楼", httpMethod = "POST", notes = "这是用来新增机场航站楼的接口")
    @PostMapping("addAirportTerminal")
    public ReturnData addAirportTerminal(@RequestBody AirportTerminal airportTerminal) {
        airportTerminalService.addAirportTerminal(airportTerminal);
        return new ReturnData();
    }

    @ApiOperation(value = "修改机场航站楼", httpMethod = "POST", notes = "这是用来修改机场航站楼的接口")
    @PostMapping("updateAirportTerminal")
    public ReturnData updateAirportTerminal(@RequestBody AirportTerminal airportTerminal) {
        airportTerminalService.updateAirportTerminal(airportTerminal);
        return new ReturnData();
    }

    @ApiOperation(value = "删除机场航站楼", httpMethod = "POST", notes = "这是用来删除机场航站楼的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "用户ID", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @PostMapping("removeAirportTerminal")
    public ReturnData removeAirportTerminal(@RequestParam Long kid) {
        airportTerminalService.removeAirportTerminal(kid);
        return new ReturnData();
    }

    @ApiOperation(value = "查询机场泊车位", httpMethod = "GET", notes = "这是用来查询机场泊车位的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "airportId", value = "机场id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "airportTerminalId", value = "航站楼id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping("getAirportParkingList")
    public ReturnData<List<AirportParking>> getAirportParkingList() {
        RequestData requestData = this.getRequestData();
        List<AirportParking> airportParkingList = airportParkingService.getAirportParkingList(requestData);
        return new ReturnData<>(airportParkingList);
    }

    @ApiOperation(value = "新增机场泊车位", httpMethod = "POST", notes = "这是用来新增机场泊车位的接口")
    @PostMapping("addAirportParking")
    public ReturnData addAirportParking(@RequestBody AirportParking airportParking) {
        airportParkingService.addAirportParking(airportParking);
        return new ReturnData();
    }

    @ApiOperation(value = "修改机场泊车位", httpMethod = "POST", notes = "这是用来修改机场泊车位的接口")
    @PostMapping("updateAirportParking")
    public ReturnData updateAirportParking(@RequestBody AirportParking airportParking) {
        airportParkingService.updateAirportParking(airportParking);
        return new ReturnData();
    }

    @ApiOperation(value = "删除机场泊车位", httpMethod = "POST", notes = "这是用来删除机场泊车位的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "用户ID", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @PostMapping("removeAirportParking")
    public ReturnData removeAirportParking(@RequestParam Long kid) {
        airportParkingService.removeAirportParking(kid);
        return new ReturnData();
    }
}
